<template>
    <div class="template-index-Lu">
        <commpVxeTable
            :isCanWrap="true"
            :key="reCommpVxeTable"
            :conditionBtnRow="true"
            :config="dataTableConfig"
            :columns="columnsVxe"
            :formItem="formItem"
            @checkboxChange="checkboxChange"
            ref="administrativeOffice"
            @searchEvent="searchEvent"
            @resetEvent="resetEvent"
            >
            <template v-slot:externalOperations="{data}"  >
                <vxe-form-item>
                    <template>
                        <a-button class="blue-btn" type="primary" @click="opdataClick()" icon="reload">更新企业回复状态</a-button>
                    </template>
                </vxe-form-item>
                <vxe-form-item>
                    <template>
                        <a-button class="blue-btn" type="primary" @click="shareQRCodeClick()" icon="link">分享二维码</a-button>
                    </template>
                </vxe-form-item>
            </template>
            <template v-slot:operation_ftjzt="{row}" data-desc="提交状态">
                <span v-if="row.ftjzt == '0'" style="color: #ee6666;">未提交</span>
                <span v-if="row.ftjzt == '1'" style="color: #91cc75;">已提交</span>
            </template>
            <template v-slot:operation_fclzt="{row}" data-desc="处理状态">
                <span v-if="row.fclzt == '0'" style="color: #ee6666;">未处理</span>
                <span v-if="row.fclzt == '1'" style="color: #91cc75;">已处理</span>
                <span v-if="row.fclzt == '2'" style="color: #00BFFF;">处理中</span>
            </template>
            <template v-slot:operation_fsftgsh="{row}" data-desc="是否通过审核">
                <span v-if="row.fsftgsh == '0'" style="color: #ee6666;">未通过</span>
                <span v-if="row.fsftgsh == '1'" style="color: #91cc75;">通过</span>
            </template>
            <template v-slot:operation_fqyhfzt="{row}" data-desc="企业回复状态">
                <span v-if="row.fqyhfzt == '0'" style="color: #ee6666;">未回复</span>
                <span v-if="row.fqyhfzt == '1'" style="color: #91cc75;">已回复</span>
            </template>
            <template v-slot:operation_btn="{row}" data-desc="自定操作栏">
                <a-form layout="inline">
                    <a-form-item>
                        <a-button class="green-btn" @click="reviseClick(row)" icon="eye">查看</a-button>
                    </a-form-item>
                </a-form>
            </template>
        </commpVxeTable>
        <increase ref="refModel"/><!-- 查看的 -->
        <QRQueryResults ref="QRQueryResultsRef" />
    </div>
</template>
<script>
import  assessCheckApi  from './service/api.js'
import {list,getreturnmsg} from './service/index'
import  commpVxeTable   from '@/components/commp-vxe-table/commp-vxe-table.vue'
import increase from './increase.vue'
import QRQueryResults from './QRQueryResults'
export default {
    components: {
        commpVxeTable,
        increase,
        QRQueryResults
    },
    props:{
    },
    data() {
        return {
            reCommpVxeTable: '',
            dataTableConfig: {
                api: assessCheckApi.list,
                rowId: 'id',
                urlType: true,
                paramet: {
                }
            },
            columnsVxe: [
                {
                    type: 'checkbox',
                    width: 60,
                    fixed: 'left'
                },{
                    title: '申请企业名称',
                    field: 'fsqqymc',
                },{
                    title: '预约日期',
                    field: 'fyyrq',
                    width: 130,
                },
                // {
                //     title: '主要咨询问题',
                //     field: 'fzyzxwt',
                // },
                {
                    title: '咨询类别',
                    field: 'fzxsx',
                },
                {
                    title: '提交状态',
                    field: 'ftjzt',
                    width: 100,
                    slots: {
                    // 使用插槽模板渲染
                        default: 'operation_ftjzt',
                    },
                },{
                    title: '处理状态',
                    field: 'fclzt',
                    width: 100,
                    slots: {
                    // 使用插槽模板渲染
                        default: 'operation_fclzt',
                    },
                },{
                    title: '是否通过审核',
                    field: 'fsftgsh',
                    width: 110,
                    slots: {
                    // 使用插槽模板渲染
                        default: 'operation_fsftgsh',
                    },
                },{
                    title: '企业回复状态',
                    field: 'fqyhfzt',
                    width: 110,
                    slots: {
                    // 使用插槽模板渲染
                        default: 'operation_fqyhfzt',
                    },
                },{
                    title: '计划来访人数',
                    field: 'fjhlfrs',
                    width: 110,
                },
                // {
                //     title: '咨询联系人',
                //     field: 'fzxlxr',
                //     width: 100,
                // },
                // {
                //     title: '手机号',
                //     field: 'fsj',
                //     width: 120,
                // },
                {
                    title: '操作',
                    field: 'id',
                    width: 100,
                    titleInterval:true,
                    slots: {
                    // 使用插槽模板渲染
                        header:'data1_header',
                        default: 'operation_btn',
                    },
                }
            ],
            formItem: [
                    {
                        label: '申请企业名称',
                        model: 'fsqqymc',
                    },
                    {
                        label: '企业号码',
                        model: 'fsj',
                    },
                ],
            jobidList: [],
            checkList: [],
            formData: {},
            opinion: '',
            reJobid: '',
        }
    },
    methods: {
        // 勾选
        checkboxChange(val){
            //console.log('已选择',val)
            this.jobidList = []
            this.checkList = []
            this.checkList = val
            if(val.length){
                val.forEach(item => {
                    this.jobidList.push(item.jobid)
                });
            }
        },
        // 搜索
        searchEvent(){
            this.dataTableConfig.paramet = {
                ...this.dataTableConfig.paramet,
            }
            //console.log(this.dataTableConfig.paramet)
        },
        // 重置
        resetEvent(){
            this.dataTableConfig.paramet = {
                ...this.dataTableConfig.paramet,
            }
        },
        // 查看
        reviseClick(row){
            this.$refs.refModel.applicationFormVisible = true
            this.$refs.refModel.getData(row.id)
        },
        // 弹窗提交成功
        success(){
            // 刷新表格 清空id数组
            this.$refs.administrativeOffice.resetEvent()
            this.jobidList = []
        },
        shareQRCodeClick(){//分享二维码
            this.$refs.QRQueryResultsRef.visibleQRQrCode = true
            this.$refs.QRQueryResultsRef.getData()
        },
        // 更新当前页企业回复状态
        opdataClick(){
          // //console.log(item)
          let fsjList = ''
          list().then(res => {
            //console.log(res.result.records)
            res.result.records.forEach(item => {
              // fsjList.push(item.fsj)
              fsjList = fsjList + item.fsj + ';'
            })
            getreturnmsg({fsj:fsjList}).then(res => {
              if(res.code == 200){
                this.$message.success(res.message)
                this.reCommpVxeTable = Date.now()
              } else {
                this.$message.warning(res.message)
              }
            })
          })

        },
    },
}
</script>
<style>
@import url('../css/oaLess.css');
</style>
